﻿@model IEnumerable<Role.Entity.Product>
@{
    ViewBag.Title = "Index";
}
<h2>
    Index</h2>
<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table>
    <tr>
        <th>
        </th>
        <th>
            Name
        </th>
        <th>
            审核状态
        </th>
        <th>
            Info
        </th>
    </tr>
    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.ActionLink("Edit", "Edit", new { id = item.ID }) |
                @Html.ActionLink("Details", "Details", new { id = item.ID }) |
                @Html.ActionLink("Delete", "Delete", new { id = item.ID })
                @if (item.WorkFlow_Info.NextNode.HasValue)
                { <a href="#" onclick="applyFun(@item.ID,@item.WorkFlow_Info.NextNode)" title="审核">审核</a>
                }
            </td>
            <td>
                @item.Name
            </td>
            <td id="flow@(item.ID)">
                @(item.WorkFlow_Info.PrevNodeEntity == null ? string.Empty : item.WorkFlow_Info.PrevNodeEntity.Name + "=>")
                <b style="color: #f00">@item.WorkFlow_Info.Name</b>
                @(item.WorkFlow_Info.NextNodeEntity == null ? string.Empty : "=>" + item.WorkFlow_Info.NextNodeEntity.Name)
            </td>
            <td>
                @item.Info
            </td>
        </tr>
    }
</table>
<script type="text/javascript">
    function applyFun(productID, nextWorkFlowInfoID) {
        $.ajax({
            type: "POST",
            url: "/Product/ApplyWorkFlow",
            data: { productID: productID, nextWorkFlowInfoID: nextWorkFlowInfoID },
            success: function (data) {
                $("#flow" + productID).html(data.msg);
            }
        })
    }
</script>
